package com.tanhua.autoconfig;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.tanhua.properties.*;
import com.tanhua.template.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass({SendSmsRequest.class})
@EnableConfigurationProperties({SmSproperties.class,
        OssProperties.class,
        AipFaceProperties.class,
        HuanXinProperties.class,
        HuaWeiUGCProperties.class})  //配置类 配置默认约定的
public class SmSAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean(name = {"smSTemplate"})
    public SmSTemplate smSTemplate(SmSproperties smSproperties){  //配置模板类 实现功能

        return new SmSTemplate(smSproperties);
    }


    @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties) {
        return new OssTemplate(ossProperties);
    }

    @Bean
    public AipFaceTemplate aipFaceTemplate(AipFaceProperties aipFaceProperties) {
        return new AipFaceTemplate(aipFaceProperties);
    }

    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties huanXinProperties) {
        return new HuanXinTemplate(huanXinProperties);
    }

    @Bean
    public HuaWeiUGCTemplate huaWeiUGCTemplate(HuaWeiUGCProperties properties) {
        return new HuaWeiUGCTemplate(properties);
    }
}
